<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Document</title>
	<style type="text/css">
       #div1{width: 200px;height: 200px;background:red;}
	</style>
	<script type="text/javascript">
		window.onload=function(){
           var oDiv=document.getElementById("div1");
           // alert(oDiv.currentStyle.width);  IE支持
           // alert(getComputedStyle(oDiv,false).width);火狐或者谷歌
           // if(oDiv.currentStyle){
           // 	 alert(oDiv.currentStyle.width); 
           // }else{
           // 	alert(getComputedStyle(oDiv,false).width);
           // }
		}
		function getStyle(obj,name){
			if(obj.currentStyle){
				return obj.currentStyle[name];
			}else{return getComputedStyle(obj,false)[name];}
		}
		window.onload=function (){
			var oDiv=document.getElementById("div1");
			alert(getStyle(oDiv,'width'));
		}
	</script>
</head>
<body>
	<div id="div1"></div>
</body>
</html>